#include<iostream>
using namespace std;
//#include"connection.h"
#include"connectionpool.h"
int main()
{
	clock_t begin = clock();
	/*未使用线程池
	for (int i = 0; i < 1000; i++)
	{
		Connection con;
		char sql[1024] = { 0 };
		sprintf(sql, "insert into stu(id,name) values(%d,'%s')", i, "lisi");
	
		con.connect("127.0.0.1", 3306, "root", "111111", "xsydb");
		con.update(sql);
	}
	*/
	ConnectionPool *cp = ConnectionPool::getConnectionPool();
	for (int i = 0; i < 1000; i++)
	{
		char sql[1024] = { 0 };
		sprintf(sql, "insert into stu(id,name) values(%d,'%s')", i, "lisi");

	
		shared_ptr<Connection> sp = cp->getConnection();
		sp->update(sql);
	}
	clock_t end = clock();
	cout << (end - begin) << "ms" << endl;
	return 0;
}